import { useModel } from "umi";
import { useReactive } from "ahooks";

const useUpdateShelfStatus = () => {
    const { remoteData } = useModel("global");
    const { organizationUuid } = useModel("organization.info");

    const state = useReactive({
        loading: false,
        applications: [],
    });

    const updateShelfStatus = async (appUuids, appStat, callback) => {
        state.loading = true;
        let res = await remoteData({
            object: "bnt-application-operation-center-service",
            serviceName: "/developer/tools/application/batchShelfStatus",
            params: {
                appSdud: organizationUuid,
                appUuids,
                appStat,
                appPuti: new Date().getUTCTime(),
            },
        });
        res && callback && callback(res);
        state.loading = false;
    };

    return { ...state, updateShelfStatus };
};

export default useUpdateShelfStatus;
